<?php
if(!is_user_logged_in()) {
	wp_redirect(site_url()."/wp-login.php");
	exit;
}

global $wpdb,$wp_rewrite,$wp_query;
$username = $wp_query->query_vars['username'];
$uid = get_user_by('login', $username ); 
$paged = $wp_query->query_vars['paged'];

get_header();?>
<section>
<div class="container">
<div class="left_main" id="left_side">
<div class="showType">
	<!--面包屑-->
</div>
<div class="content_out">
	<div class="content">
	<div class="perContentBox">
	<div class="contentBg">
		<div class="con_title">
			<span class="conName">用户名</span> : <?php echo $username; ?><br />
			<div class="clear"></div>
            
            <?php
				/********用户资料页面********/
				
				global $wpdb, $post, $wp_query,$current_user,$userdata;
				get_currentuserinfo();
				$query_vars = $wp_query->query_vars;
				//$pagenum = isset($query_vars['paged']) ? $query_vars['paged'] : 1;
				$pagenum = isset( $_GET['pagenum'] ) ? intval( $_GET['pagenum'] ) : 1;
				$comments_total = get_user_comments_count($uid);
				$total_page = ceil($comments_total/20);
				$current = ($pagenum-1)*20;
				$args = array(
					'user_id' => get_current_user_id(),
					'status' => 'approve',
					'number' => 20,
					'offset' => $current
				);
				$coments_query = get_comments( $args );
				?>
            <div class="member_system">
            <div class="title_member"> 评论总数：<?php echo $comments_total;?></div>  
            <ul class="item-list">
               <?php $check= "select * from ".$wpdb->prefix."comments where user_id='$uid->ID' limit $current,20";
                    $coo = $wpdb->get_results($check); 	
                    if(count($coo) > 0){
                    foreach ($coo as $co) {
                    $post_of_int=get_post($co->comment_post_ID );	
                ?>  	
                    <li>
                    <div class="user_list_title"  style="line-height:28px;" >
                    <a href="<?php echo get_permalink($post_of_int->ID); ?>"> 
                    <?php echo $post_of_int->post_title;?>
                    </a>
                    </div>
                    </li>
              <?php }} ?>
            </ul>
			</div>



<?php
/********用户资料页面********/
global $wpdb, $post, $wp_query,$userdata, $wp_http_referer;
$query_vars = $wp_query->query_vars;
$pagenum = isset( $_GET['pagenum'] ) ? intval( $_GET['pagenum'] ) : 1;
$args = array(
	'author' => $uid->ID,
	'post_status' => array('publish'),
	//'post_type' => 'detail',
	'posts_per_page' => 20,
	'paged' => $pagenum
);
$dashboard_query = new WP_Query( $args );
?>

<div class="member_system">
    <div class="title_member" >总共发表文章：<?php echo $dashboard_query->found_posts;?>篇</div>
<?php if( $dashboard_query->have_posts() ) : ?>
<ul class="item-list" >
	<?php while ( $dashboard_query->have_posts() ) : $dashboard_query->the_post(); ?>
    <li> 
    <div class="item-info">
        <div class="user_list_title"  >
         <a href="<?php the_permalink(); ?>" target="_blank"><?php echo get_the_title();?></a>   
        </div>
    </div> 
    </li>
    <?php endwhile;?>  
</ul>
<?php
endif;
?>
</div>




 


		</div>
        
        
        
		<div class="showLeft">
		<!--内容区-->
		</div>
		<div class="clear"></div>
	</div>
	</div>

	</div>
	</div>
</div>
<?php get_sidebar();?>
<div class="clear"></div>
</div>
</section>
<?php get_footer();?>